<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>分析生命周期</title>
    <script src="../js/vue.js"></script>
</head>
<body>
    <div id="root">
        <h2>当前n值：{{n}}</h2>
        <button @click="add">点我n+1</button>
        <button @click="des">点我销毁vm</button>
    </div>

    <script>
        new Vue({
            el:'#root',
            // template:`
            //     <div>
            //         <h2>当前n值：{{n}}</h2>
            //         <button @click="add">点我n+1</button>
            //     </div>
            // `,
            data:{
                n:1
            },
            methods:{
                add(){
                    this.n++
                },
                des(){
                    this.$destroy()
                    console.log('des')
                }
                
            },
            beforeCreate(){
                    console.log('beforeCreate')
                    console.log(this)
                    // debugger;
                    console.log('debugger')
            },
            beforeMount(){
                console.log('beforeMount')
            },
            mounted(){
                console.log('mounted')
                console.log(this)
            },
            beforeUpdate(){
                console.log('beforeUpdate')//数据更新时调用
                // debugger
            },
            updated(){
                console.log('updated')
                // debugger
            },
            beforeDestroy(){
                console.log('beforeDestroy')
            },
            destroyed(){
                console.log('destroyed')
            }
        })
    </script>
</body>
</html>